]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Make St aware of the UI group.
authorGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 11 Jan 2011 15:38:55 +0000 (16:38 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 22 Mar 2011 15:09:23 +0000 (16:09 +0100)
Inside the Shell, all the UI (including chrome, the overview, and
the actual windows) is not a child of the stage but of a special
ClutterGroup, which is cloned inside the magnifier.
Add function for setting this special actor so that actors added by
St are visible in the magnifier. Nothing yet uses this, but the
tooltip will soon.

https://bugzilla.gnome.org/show_bug.cgi?id=635100

js/ui/main.js
src/st/st-widget.c
src/st/st-widget.h

index 155cdb2991752a80aad61d8cad18dae5d3ddd623..603f485223cc3c854357311baea9f6189299560a 100644 (file)
@@ -136,6 +136,7 @@ function start() {
 
     // Set up stage hierarchy to group all UI actors under one container.
     uiGroup = new Clutter.Group();
+    St.set_ui_root(global.stage, uiGroup);
     global.window_group.reparent(uiGroup);
     global.overlay_group.reparent(uiGroup);
     global.stage.add_actor(uiGroup);
index 45b3f8db999c2f078a7b1ead4c9783f3830c125d..fe5d1b0c51e461f4db426213e4ac67709ca8e1ca 100644 (file)
@@ -2222,3 +2222,71 @@ on_can_focus_notify (GObject    *gobject,
   atk_object_notify_state_change (ATK_OBJECT (data),
                                   ATK_STATE_FOCUSABLE, can_focus);
 }
+
+static GQuark
+st_ui_root_quark (void)
+{
+  static GQuark value = 0;
+  if (G_UNLIKELY (value == 0))
+    value = g_quark_from_static_string ("st-ui-root");
+  return value;
+}
+
+static void
+st_ui_root_destroyed (ClutterActor *actor,
+                      ClutterStage *stage)
+{
+  st_set_ui_root (stage, NULL);
+  g_signal_handlers_disconnect_by_func (actor, st_ui_root_destroyed, stage);
+}
+
+/**
+ * st_get_ui_root:
+ * @stage: a #ClutterStage
+ * @container: (allow-none): the new UI root
+ *
+ * Sets a #ClutterContainer to be the parent of all UI in the program.
+ * This container is used when St needs to add new content outside the
+ * widget hierarchy, for example, when it shows a tooltip over a widget.
+ */
+void
+st_set_ui_root (ClutterStage     *stage,
+                ClutterContainer *container)
+{
+  ClutterContainer *previous;
+
+  g_return_if_fail (CLUTTER_IS_STAGE (stage));
+  g_return_if_fail (CLUTTER_IS_CONTAINER (container));
+
+  previous = st_get_ui_root (stage);
+  if (previous)
+    g_signal_handlers_disconnect_by_func (container, st_ui_root_destroyed, stage);
+
+  if (container)
+    {
+      g_signal_connect (container, "destroy", G_CALLBACK (st_ui_root_destroyed), stage);
+      g_object_set_qdata_full (G_OBJECT (stage), st_ui_root_quark (), g_object_ref (container), g_object_unref);
+    }
+}
+
+/**
+ * st_get_ui_root:
+ * @stage: a #ClutterStage
+ *
+ * Returns: (transfer none): the container which should be the parent of all user interface,
+ *   which can be set with st_set_ui_root(). If not set, returns @stage
+ */
+ClutterContainer *
+st_get_ui_root (ClutterStage *stage)
+{
+  ClutterContainer *root;
+
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
+
+  root = g_object_get_qdata (G_OBJECT (stage), st_ui_root_quark ());
+
+  if (root != NULL)
+    return root;
+  else
+    return CLUTTER_CONTAINER (stage);
+}
index 7f5efec7aa41edf3a4807aa022ef69a279b49672..d38eb68932d97df0c47870bed58eb70cd83a0ce2 100644 (file)
@@ -162,6 +162,10 @@ char  *st_describe_actor       (ClutterActor *actor);
 void   st_set_slow_down_factor (gfloat factor);
 gfloat st_get_slow_down_factor (void);
 
+void              st_set_ui_root (ClutterStage     *stage,
+                                  ClutterContainer *container);
+ClutterContainer *st_get_ui_root (ClutterStage     *stage);
+
 G_END_DECLS
 
 #endif /* __ST_WIDGET_H__ */